<#
任务与里程碑文档检查（原生 PowerShell）
用途：验证 rules/tasks_index.md 是否存在，且 docs/milestones.md 是否引用它。
用法：
  pwsh -File scripts/windows/check-task-docs.ps1
#>
param()

$WindowsDir = Split-Path -Parent $PSCommandPath
$ScriptsDir = Split-Path -Parent $WindowsDir
$RepoDir = Split-Path -Parent $ScriptsDir

$tasks = Join-Path $RepoDir 'rules/tasks_index.md'
$milestones = Join-Path $RepoDir 'docs/milestones.md'

$ok = $true
if (!(Test-Path $tasks)) { Write-Warning "缺少任务索引：$tasks"; $ok = $false }
if (!(Test-Path $milestones)) { Write-Warning "缺少里程碑文档：$milestones"; $ok = $false }
elseif ((Get-Content -Raw $milestones) -notmatch [regex]::Escape('rules/tasks_index.md')) { Write-Warning "milestones.md 未引用 tasks_index.md"; $ok = $false }

if ($ok) { Write-Host "任务与里程碑文档检查通过"; exit 0 } else { exit 2 }
